Also only store port number of console event channel.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
{ 0 },
};
- char *str_pty;
- char path[1024];
+ char *str_pty, *path;
int spty;
unsigned int len = 0;
struct xs_handle *xs;
signal(SIGTERM, sighandler);
- snprintf(path, sizeof(path), "/console/%d/tty", domid);
+ path = xs_get_domain_path(xs, domid);
+ if (path == NULL)
+ err(errno, "xs_get_domain_path()");
+ path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
+ if (path == NULL)
+ err(ENOMEM, "realloc");
+ strcat(path, "/console/tty");
str_pty = xs_read(xs, path, &len);
/* FIXME consoled currently does not assume domain-0 doesn't have a
err(errno, "Could not open tty `%s'", str_pty);
}
free(str_pty);
+ free(path);
init_term(STDIN_FILENO, &attr);
console_loop(xc_handle, domid, spty);
{
char *path;
int master;
+ bool success;
if ((master = getpt()) == -1 ||
grantpt(master) == -1 || unlockpt(master) == -1) {
tcsetattr(master, TCSAFLUSH, &term);
}
- asprintf(&path, "/console/%d/tty", dom->domid);
- xs_write(xs, path, slave, strlen(slave), O_CREAT);
+ success = asprintf(&path, "%s/tty", dom->conspath) != -1;
+ if (!success)
+ goto out;
+ success = xs_write(xs, path, slave, strlen(slave), O_CREAT);
free(path);
+ if (!success)
+ goto out;
- asprintf(&path, "/console/%d/limit", dom->domid);
+ success = asprintf(&path, "%s/limit", dom->conspath) != -1;
+ if (!success)
+ goto out;
data = xs_read(xs, path, &len);
if (data) {
dom->buffer.max_capacity = strtoul(data, 0, 0);
}
return master;
+ out:
+ close(master);
+ return -1;
}
/* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
err = xs_gather(xs, dom->conspath,
"ring-ref", "%u", &ring_ref,
- "console_channel/port1", "%i", &local_port,
+ "port", "%i", &local_port,
NULL);
if (err)
goto out;
}
dom->domid = domid;
+
+ dom->conspath = xs_get_domain_path(xs, dom->domid);
+ if (dom->conspath == NULL)
+ goto out;
+ s = realloc(dom->conspath, strlen(dom->conspath) +
+ strlen("/console") + 1);
+ if (s == NULL)
+ goto out;
+ dom->conspath = s;
+ strcat(dom->conspath, "/console");
+
dom->tty_fd = domain_create_tty(dom);
dom->is_dead = false;
dom->buffer.data = 0;
dom->page = NULL;
dom->evtchn_fd = -1;
- dom->conspath = NULL;
-
- dom->conspath = xs_get_domain_path(xs, dom->domid);
- if (dom->conspath == NULL)
- goto out;
- s = realloc(dom->conspath, strlen(dom->conspath) +
- strlen("/console") + 1);
- if (s == NULL)
- goto out;
- dom->conspath = s;
- strcat(dom->conspath, "/console");
-
if (!watch_domain(dom, true))
goto out;
if m:
dominfo.console_mfn = int(m.group(2))
dominfo.exportToDB(save=True, sync=True)
- dominfo.publish_console()
try:
l = child.fromchild.readline()
except:
self.store_channel.saveToDB(self.db.addChild("store_channel"),
save=save)
if self.console_channel:
- self.console_channel.saveToDB(self.db.addChild("console/console_channel"),
- save=save)
+ self.db['console/port'] = "%i" % self.console_channel.port1
if self.image:
self.image.exportToDB(save=save, sync=sync)
self.db.exportToDB(self, fields=self.__exports__, save=save, sync=sync)
def importFromDB(self):
self.db.importFromDB(self, fields=self.__exports__)
- self.store_channel = self.eventChannel("store_channel")
+ self.store_channel = self.eventChannelOld("store_channel")
def setdom(self, dom):
"""Set the domain id.
self.configure_restart()
self.construct_image()
self.configure()
- self.publish_console()
self.exportToDB(save=True)
except Exception, ex:
# Catch errors, cleanup and re-raise.
id, self.name, self.memory)
self.setdom(id)
- def eventChannel(self, key):
+ def eventChannelOld(self, key):
"""Create an event channel to the domain.
If saved info is available recreate the channel.
db = self.db.addChild(key)
return EventChannel.restoreFromDB(db, 0, self.id)
+ def eventChannel(self, path=None, key=None):
+ """Create an event channel to the domain.
+
+ @param path under which port is stored in db
+ """
+ port = 0
+ try:
+ if path and key:
+ if path:
+ db = self.db.addChild(path)
+ else:
+ db = self.db
+ port = int(db[key].getData())
+ except: pass
+ return EventChannel.interdomain(0, self.id, port1=port, port2=0)
+
def create_channel(self):
"""Create the channels to the domain.
"""
- self.store_channel = self.eventChannel("store_channel")
- self.console_channel = self.eventChannel("console/console_channel")
+ self.store_channel = self.eventChannelOld("store_channel")
+ self.console_channel = self.eventChannel("console", "port")
def create_configured_devices(self):
devices = sxp.children(self.config, 'device')
backend = blkif.getBackend(0)
backend.connect(recreate=self.recreate)
- def publish_console(self):
- db = DBMap(db=XenNode("/console/%d" % self.id))
- db['domain'] = self.db.getPath()
- db.saveDB(save=True)
-
def configure_fields(self):
"""Process the vm configuration fields using the registered handlers.
"""
def dom0_init_store(self):
if not self.store_channel:
- self.store_channel = self.eventChannel("store_channel")
+ self.store_channel = self.eventChannelOld("store_channel")
self.store_mfn = xc.init_store(self.store_channel.port2)
if self.store_mfn >= 0:
self.db.introduceDomain(self.id, self.store_mfn,